//
//  FillLearnTableViewCell.swift
//  fsapp
//
//  Created by zguang on 17/7/29.
//  Copyright © 2017年 huangshengjie. All rights reserved.
//

import UIKit

class FillLearnTableViewCell: UITableViewCell {
    let title = UILabel()
    let backImage = UIImageView()
    let playButton = UIButton()
    let timeSpan = UILabel()
    let money = UILabel()
    let videoCount = UIButton()
    let likeCount = UIButton()
    let coommitCount = UIButton()
    let starCount = UIButton()
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
    
    func setUI(){
    
         var countSort:UIButton = {
            let button = UIButton(frame:CGRect(x:getWidth(width: 573),y:getHeight(20),width:getWidth(width: 85),height:getHeight(26)))
            button.setTitle("价格", for: .normal)
            button.setTitleColor(UIColor.gray, for: .normal)
            button.setTitleColor(UIColor.blue, for: .selected)
            return button
        }()
        
        var cellBackView:UIView = {
            let view = UIView(frame:CGRect(x:0,y:0,width:SCREEN_WIDTH,height:getHeight(470)))
            return view
        }()
        let upview = UIView(frame:CGRect(x:0,y:0,width:SCREEN_WIDTH,height:getHeight(94)))
        upview.backgroundColor = UIColor.init(red: 0/255, green: 0/255, blue: 0/255, alpha: 0.5)
        
        
        title.frame = CGRect(x:getWidth(width: 19),y:getHeight(20),width:SCREEN_WIDTH -  getWidth(width: 19),height:getHeight(26))
        title.textColor = UIColor.white
        
        
        backImage.frame = CGRect(x:0,y:0,width:SCREEN_WIDTH,height:getHeight(400))
        
        
        playButton.frame = CGRect(x:SCREEN_WIDTH/2 - getWidth(width: 90)/2,y:getHeight(200 - 45),width:getWidth(width: 90),height:getHeight(90))
        playButton.setImage(#imageLiteral(resourceName: "播放"), for: .normal)
        timeSpan.frame = CGRect(x:SCREEN_WIDTH - getWidth(width: 100),y:getHeight(400 - 45),width:getWidth(width: 100),height:getHeight(45))
        timeSpan.font = UIFont.systemFont(ofSize: height(28))
       // timeSpan.backgroundColor = UIColor.black
        timeSpan.textColor = UIColor.white
    
        let bottomView = UIView(frame:CGRect(x:0,y:getHeight(400),width:SCREEN_WIDTH,height:getHeight(70)))
        money.frame = CGRect(x:getWidth(width: 11),y:getHeight(20),width:getWidth(width: 76),height:getHeight(26))
        money.textColor = UIColor.red
        money.adjustsFontSizeToFitWidth = true
        
        videoCount.frame = CGRect(x:getWidth(width: 255),y:getHeight(15),width:getWidth(width: 100),height:getHeight(41))
       // videoCount.titleLabel?.adjustsFontSizeToFitWidth = true
        videoCount.setTitleColor(UIColor.black, for: .normal)
        
        
        likeCount.frame = CGRect(x:getWidth(width: 255+38+80),y:getHeight(15),width:getWidth(width: 100),height:getHeight(41))
       // likeCount.titleLabel?.adjustsFontSizeToFitWidth = true
        likeCount.setTitleColor(UIColor.black, for: .normal)
        
        
        coommitCount.frame = CGRect(x:getWidth(width: 255+(38+80)*2),y:getHeight(15),width:getWidth(width: 100),height:getHeight(41))
        //coommitCount.titleLabel?.adjustsFontSizeToFitWidth = true\
        coommitCount.setTitleColor(UIColor.black, for: .normal)
        starCount.frame = CGRect(x:getWidth(width: 255 + (38+80)*3),y:getHeight(15),width:getWidth(width: 100),height:getHeight(41))
       // starCount.titleLabel?.adjustsFontSizeToFitWidth = true
        starCount.setTitleColor(UIColor.black, for: .normal)
        
        videoCount.titleEdgeInsets = UIEdgeInsets.init(top: 0, left: width(-49), bottom: 0, right: 0)
        coommitCount.titleEdgeInsets = UIEdgeInsets.init(top: 0, left: width(-49), bottom: 0, right: 0)
        starCount.titleEdgeInsets = UIEdgeInsets.init(top: 0, left: width(-33), bottom: 0, right: 0)
        likeCount.titleEdgeInsets = UIEdgeInsets.init(top: 0, left: width(-33), bottom: 0, right: 0)
       
        
        videoCount.titleLabel?.font = UIFont.systemFont(ofSize: height(26))
        starCount.titleLabel?.font = UIFont.systemFont(ofSize: height(26))
        coommitCount.titleLabel?.font = UIFont.systemFont(ofSize: height(26))
        likeCount.titleLabel?.font = UIFont.systemFont(ofSize: height(26))
        
//        videoCount.titleLabel?.sizeToFit()
//        starCount.titleLabel?.sizeToFit()
//        likeCount.titleLabel?.sizeToFit()
//        coommitCount.titleLabel?.sizeToFit()
        
        
        videoCount.imageEdgeInsets = UIEdgeInsets.init(top: 0, left: 0, bottom: 0, right: width(60))
        likeCount.imageEdgeInsets = UIEdgeInsets.init(top: 0, left: 0, bottom: 0, right: width(60));
        coommitCount.imageEdgeInsets = UIEdgeInsets.init(top: 0, left: 0, bottom: 0, right: width(60));
        starCount.imageEdgeInsets = UIEdgeInsets.init(top: 0, left: 0, bottom: 0, right: width(60));
        likeCount.setImage(#imageLiteral(resourceName: "点赞"), for: .normal)
        likeCount.setImage(#imageLiteral(resourceName: "点赞-红"), for: .selected)
        videoCount.setImage(#imageLiteral(resourceName: "播放量 "), for: .normal)
        coommitCount.setImage(#imageLiteral(resourceName: "评论"), for: .normal)
        starCount.setImage(#imageLiteral(resourceName: "收藏"), for: .normal)
        starCount.setImage(#imageLiteral(resourceName: "收藏-红"), for: .selected)
        bottomView.addSubview(money)
        bottomView.addSubview(videoCount)
        bottomView.addSubview(likeCount)
        bottomView.addSubview(coommitCount)
        bottomView.addSubview(starCount)
        cellBackView.addSubview(backImage)
         cellBackView.addSubview(upview)
        cellBackView.addSubview(title)
        cellBackView.addSubview(playButton)
        cellBackView.addSubview(timeSpan)
        cellBackView.addSubview(bottomView)
       
        self.addSubview(cellBackView)
    
    }

}
